11. House your Robot

House your Robot

So far, you created a robot model from scratch, added sensors to it to visualize its surroundings, and developed a package to launch the robot in a simulated environment. That's a real accomplishment!

But you haven’t yet placed the robot in an environment. Let’s house it inside the world you built in Build My World project.

Adding the World File

Copy the <yourname>.world file from the world directory of the ** Build My World** project and paste it in the worlds directory of my_robot.

Inside your package’s worlds directory you should now see two files - the empty.world that we created earlier and the <yourname>.world file that you just added.

Feel free to delete the empty.world file. We won’t need it anymore.

Launch the World

Edit the world.launch file and add a reference to the <yourname>.world file that you just added. To do so, open the world.launch file and edit this line:

<arg name="world_file" default="$(find my_robot)/worlds/empty.world"/>

Replace it with this:

<arg name="world_file" default="$(find my_robot)/worlds/<yourname>.world"/>

Launch!

Now, that you’ve added your world file to the my_robot package, let’s launch and visualize our robot inside our home.

$ cd /home/workspace/catkin_ws/
$ source devel/setup.bash
$ roslaunch my_robot world.launch

Initialize the Robot’s Position and Orientation

As you can see, my robot’s initial position is outside of my world! You might face the same problem. I have to change my robot’s initial pose: its position and orientation. This can be done through editing the world.launch file:

  <!-- Robot pose -->
  <arg name="x" default="0"/>
  <arg name="y" default="0"/>
  <arg name="z" default="0"/>
  <arg name="roll" default="0"/>
  <arg name="pitch" default="0"/>
  <arg name="yaw" default="0"/>

The best way to figure out these numbers is to change the robot’s position and orientation within Gazebo, record its pose, and then update the launch file.

Task Description:

Follow these steps to house your robot inside your world:

Task List:

Task Feedback:

Great job!